import Vue from 'vue'
import { Loading } from '@femessage/element-ui'

export class CommonUtils {
    static tableLoading(api, gridOptions) {
        if (gridOptions) {
            gridOptions.loading = true;
            Vue.prototype.$loadingGridOptions = gridOptions;
        }
        return api;
    }

    static globalLoading(api) {
        let loadingInstance;
        new Promise((resolve) => {
            Vue.prototype.$globalLoadingResolve = resolve;
            loadingInstance = Loading.service({
                lock: true, // lock的修改符--默认是false
                text: '拼命加载中...', // 显示在加载图标下方的加载文案
                spinner: 'el-icon-loading', // 自定义加载图标类名
                background: 'rgb(215 215 215 / 70%)', // 遮罩层颜色
            });
        }).then(() => {
            loadingInstance.close();
        });
        return api;
    }
}